/*
 * Copyright 2008-2023 dexian.vip. All rights reserved.
 * Support: http://www.dexian.vip
 * License: http://www.dexian.vip/license
 */

package vip.dexian.admin.entity;

import vip.dexian.admin.enums.SensitiveLogTypeEnum;
import vip.dexian.core.base.bean.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Where;

import java.io.Serial;

/**
 * 敏感日志
 *
 * @author 挺好的 2023年06月07日 13:46
 */
@Entity
@Table (name = "br_admin_sensitive_log", indexes = {@Index (name = "is_valid", columnList = "isValid")})
@DynamicUpdate
@Where (clause = BaseEntity.IS_VALID_WHERE)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode (callSuper = true)
public class SensitiveLog extends BaseEntity <Long> {

    @Serial
    private static final long serialVersionUID = 7489310122990030295L;

    /**
     * 管理员id
     */
    @Comment ("管理员id")
    @Column (nullable = false, updatable = false)
    private Long adminId;

    /**
     * 操作员， {@link vip.dexian.admin.dto.AdminPrincipal#getOperator()} or {@link Admin#getOperator()}
     */
    @Comment ("操作员")
    @Column (nullable = false, updatable = false, length = 32)
    private String operator;

    /**
     * 日志类型
     */
    @Comment ("日志类型。0：修改密码，1：启用禁用，2：锁定解锁，3：修改角色")
    @Column (nullable = false, updatable = false)
    private SensitiveLogTypeEnum type;

    /**
     * 原值
     */
    @Comment ("修改前的值")
    @Column
    private String oldValue;

    /**
     * 新值
     */
    @Comment ("修改后的值")
    @Column (length = 500)
    private String newValue;

    /**
     * 备注
     */
    @Comment ("备注")
    @Column
    private String memo;


}
